package cn.itcast.cd.service.impl;

import cn.itcast.cd.dao.IBaseDao;
import cn.itcast.cd.dao.IUserDao;
import cn.itcast.cd.domain.User;
import cn.itcast.cd.query.IQuery;
import cn.itcast.cd.resultPage.ResultPage;
import cn.itcast.cd.service.IUserService;
import cn.itcast.cd.utils.MD5;

public class UserServiceImpl implements IUserService {

	private IUserDao userDao;
	
	public void setUserDao(IUserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public void save(User user) {
		user.setPassword(MD5.encode(user.getPassword()));
		userDao.save(user);
	}

	@Override
	public User get(Long id) {
		return (User) userDao.get(id);
	}

	@Override
	public ResultPage query(String hql, Object[] params, int start, int limit) {
		return userDao.query(hql, params, start, limit);
	}

	@Override
	public void delete(Long id) {
		userDao.delete(id);
	}

	@Override
	public void update(User user) {
		userDao.update(user);
	}

	@Override
	public ResultPage queryEntity(IQuery query) {
		
		return userDao.queryEntity(query);
	}

}
